<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\shop\controller;

class AdminSetting extends \app\AdminRest
{
    protected $model;
    public function __construct(\think\App $app)
    {
        parent::__construct($app);
        $this->model = new \app\shop\model\Config();
    }
    public function configInfo()
    {
        $dis = ["uniacid" => $this->_uniacid];
        $data = $this->model->dataInfo($dis);
        return $this->success($data);
    }
    public function configUpdate()
    {
        $input = $this->_input;
        $dis = ["uniacid" => $this->_uniacid];
        $data = $this->model->dataUpdate($dis, $input);
        return $this->success($data);
    }
    public function bannerList()
    {
        $input = $this->_param;
        $dis[] = ["uniacid", "=", $this->_uniacid];
        $dis[] = ["status", ">", -1];
        $banner_model = new \app\shop\model\Banner();
        $data = $banner_model->dataList($dis, $input["limit"]);
        return $this->success($data);
    }
    public function bannerAdd()
    {
        $input = $this->_input;
        $input["uniacid"] = $this->_uniacid;
        $banner_model = new \app\shop\model\Banner();
        $res = $banner_model->dataAdd($input);
        return $this->success($res);
    }
    public function bannerUpdate()
    {
        $input = $this->_input;
        $dis = ["id" => $input["id"]];
        $banner_model = new \app\shop\model\Banner();
        $res = $banner_model->dataUpdate($dis, $input);
        return $this->success($res);
    }
    public function bannerInfo()
    {
        $input = $this->_param;
        $dis = ["id" => $input["id"]];
        $banner_model = new \app\shop\model\Banner();
        $res = $banner_model->dataInfo($dis);
        return $this->success($res);
    }
    public function articleList()
    {
        $input = $this->_param;
        $article_model = new \app\shop\model\Article();
        $dis[] = ["uniacid", "=", $this->_uniacid];
        $dis[] = ["status", ">", -1];
        if(!empty($input["title"])) {
            $dis[] = ["title", "like", "%" . $input["title"] . "%"];
        }
        $data = $article_model->dataList($dis, $input["limit"]);
        return $this->success($data);
    }
    public function articleAdd()
    {
        $input = $this->_input;
        $article_model = new \app\shop\model\Article();
        $input["uniacid"] = $this->_uniacid;
        $res = $article_model->dataAdd($input);
        return $this->success($res);
    }
    public function articleUpdate()
    {
        $input = $this->_input;
        $article_model = new \app\shop\model\Article();
        $dis = ["id" => $input["id"]];
        $res = $article_model->dataUpdate($dis, $input);
        return $this->success($res);
    }
    public function articleInfo()
    {
        $input = $this->_param;
        $article_model = new \app\shop\model\Article();
        $dis = ["id" => $input["id"]];
        $res = $article_model->dataInfo($dis);
        return $this->success($res);
    }
    public function articleSelect()
    {
        $input = $this->_param;
        $article_model = new \app\shop\model\Article();
        $dis = ["uniacid" => $this->_uniacid, "status" => 1];
        $res = $article_model->where($dis)->field("id,title")->select()->toArray();
        return $this->success($res);
    }
    public function payConfigInfo()
    {
        $dis = ["uniacid" => $this->_uniacid];
        $pay_model = new \app\shop\model\PayConfig();
        $data = $pay_model->dataInfo($dis);
        return $this->success($data);
    }
    public function payConfigUpdate()
    {
        $input = $this->_input;
        $dis = ["uniacid" => $this->_uniacid];
        if(!strstr($input["cert_path"], FILE_UPLOAD_PATH)) {
            $input["cert_path"] = FILE_UPLOAD_PATH . $input["cert_path"];
        }
        if(!strstr($input["key_path"], FILE_UPLOAD_PATH)) {
            $input["key_path"] = FILE_UPLOAD_PATH . $input["key_path"];
        }
        $pay_model = new \app\shop\model\PayConfig();
        $data = $pay_model->dataUpdate($dis, $input);
        return $this->success($data);
    }
    public function updatePass()
    {
        $input = $this->_input;
        $admin = new \app\shop\model\Admin();
        $update = ["passwd" => checkPass($input["pass"])];
        $res = $admin->dataUpdate(["uniacid" => $this->_uniacid], $update);
        return $this->success($res);
    }
    public function msgConfigInfo()
    {
        $msg_model = new \app\shop\model\MsgConfig();
        $dis = ["uniacid" => $this->_uniacid];
        $data = $msg_model->dataInfo($dis);
        return $this->success($data);
    }
    public function msgConfigUpdate()
    {
        $input = $this->_input;
        $msg_model = new \app\shop\model\MsgConfig();
        $dis = ["uniacid" => $this->_uniacid];
        $data = $msg_model->dataUpdate($dis, $input);
        return $this->success($data);
    }
}

?>